﻿using NetServ.Net.Json;

namespace Ria.Infrastructure
{
    static class JsonObjectExtender
    {
        /// <summary>
        /// Extender converts JsonObject to JSON string
        /// </summary>
        /// <param name="type">object to convert</param>
        /// <returns>JSON string</returns>
        public static string ToJsonString(this IJsonType type)
        {
            string json;
            using (var jsonWriter = new JsonWriter())
            {
                type.Write(jsonWriter);
                json = jsonWriter.ToString();
            }
            return json;
        }
    }
}
